package com.ruoyi.system.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.system.domain.TbComponentinfo;
import com.ruoyi.system.service.ITbComponentinfoService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @author: zhoupeng
 * @date: 2021/9/16 22:40
 * @descreption: 配件统计
 */
@Controller
@RequestMapping("/system/partsStatistic")
public class PartsStatistic extends BaseController {

    private String prefix = "system/partsStatistic";

    @Resource
    private ITbComponentinfoService tbComponentinfoService;

    @RequiresPermissions("system:partsStatistic:view")
    @GetMapping()
    public String partsStatistic() {
        return prefix + "/partsStatistic";
    }

    /**
     * 查询配件以及数量
     *
     * @param tbComponentinfo TbComponentinfo
     * @return 集合
     */
    @PostMapping("partAndCountList")
    @ResponseBody
    public JSONArray selectRegisterNoAndCount(TbComponentinfo tbComponentinfo) {
        return (JSONArray) JSON.toJSON(tbComponentinfoService.partAndCountList(tbComponentinfo));
    }
}
